<!DOCTYPE html>
<script src='/js-test-resources/gesture-util.js'></script>
<style>
html {
  width: 100%;
  height: 100%;
}
body {
  width: 100%;
  height: 10000px;
}
</style>

<script>

window.addEventListener('message', async (e) => {
  var framePosition = e.data.framePosition;
  var x = framePosition.x + window.innerWidth / 2;
  var y = framePosition.y + window.innerHeight / 2;

  var scrollYBefore = window.scrollY;

  try {
    await smoothScroll(
        100, x, y, GestureSourceType.DEFAULT_INPUT, 'down', SPEED_INSTANT);
    var scrollYAfter = window.scrollY;
    e.source.postMessage((scrollYAfter > scrollYBefore) ? 'pass' : 'fail', '*');
  } catch (error) {
    e.source.postMessage(error.message, '*');
  }
}, { once: true });

</script>
